package com.example.kx020_button;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button button = findViewById(R.id.button1);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) { //Toast.LENGTH_SHORT 设置短时间显示弹框
                Toast.makeText(MainActivity.this, "单击了按钮1", Toast.LENGTH_SHORT).show();
            }
        });
    }


    public void button2(View view) { //Toast.LENGTH_SHORT 设置短时间显示弹框
        Toast.makeText(MainActivity.this, "单击了按钮2", Toast.LENGTH_SHORT).show();
    }











}